﻿//-----------------------------------------------------------------------
// <copyright file="CharacterClassHelper.cs" company="FastNET Services">
//     Copyright (c) 2008-2009. All Rights Reserved.
// </copyright>
// <license>
//     GPLv2
// </license>
// <warranty>
//     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
//     BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
//     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
//     DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//     OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// </warranty>
//-----------------------------------------------------------------------
#region Usings

using System;
using GateShift.Common.Repository;
using GateShift.Common.Repository.Interfaces.DataInterfaces;
using GateShift.Common.Repository.Interfaces.Repositories;
using GateShift.Services.GameData.Entities;

#endregion

namespace GateShift.Testing.Services.GameData.Helpers
{
    /// <summary>
    /// Static Unit Test Helper Class for CharacterClass Entities
    /// </summary>
    internal static class CharacterClassHelper
    {
        /// <summary>
        /// Creates a character class ready to save to the database
        /// </summary>
        /// <returns>CharacterClass with unique default values</returns>
        public static ICharacterClassData CreateCharacterClass()
        {
            return CreateCharacterClass(CharacterHelper.CreateDBCharacter().ID, ClassHelper.CreateDBClass().ID);
        }

        /// <summary>
        /// Creates a character class ready to save to the database
        /// </summary>
        /// <param name="characterID">Character Identity the mapping is for</param>
        /// <param name="classID">Class Identity the mapping is for</param>
        /// <returns>CharacterClass with unique default values</returns>
        public static ICharacterClassData CreateCharacterClass(Identity characterID, Identity classID)
        {
            ICharacterClassData characterClass = new CharacterClass();
            Random rnd = new Random();

            characterClass.CharacterID = characterID;
            characterClass.ClassID = classID;
            characterClass.Ranks = (byte)rnd.Next(byte.MinValue, byte.MaxValue);

            return characterClass;
        }

        /// <summary>
        /// Creates a character class ready pre-saved to the database
        /// </summary>
        /// <returns>CharacterClass with unique default values</returns>
        public static ICharacterClassData CreateDBCharacterClass()
        {
            return CreateDBCharacterClass(CharacterHelper.CreateDBCharacter().ID, ClassHelper.CreateDBClass().ID);
        }

        /// <summary>
        /// Creates a character class ready pre-saved to the database
        /// </summary>
        /// <param name="characterID">Character Identity the mapping is for</param>
        /// <param name="classID">Class Identity the mapping is for</param>
        /// <returns>CharacterClass with unique default values</returns>
        public static ICharacterClassData CreateDBCharacterClass(Identity characterID, Identity classID)
        {
            CharacterClass characterClass = (CharacterClass)CreateCharacterClass(characterID, classID);

            DBHelper.Provider.GetRepository<ICharacterClassRepository>().Save(characterClass);

            return characterClass;
        }
    }
}